package org.water.common.druid;

import org.aopalliance.intercept.MethodInvocation;

import com.alibaba.druid.filter.stat.StatFilterContext;
import com.alibaba.druid.support.spring.stat.DruidStatInterceptor;
import com.alibaba.druid.support.spring.stat.SpringStat;
import com.alibaba.druid.support.spring.stat.SpringStatManager;
/**
 * 方法拦截器
 * @author qzy
 *
 */
public class CustomDruidStatInterceptor extends DruidStatInterceptor {
	
	private CustomSpringMethodContextListener statContextListener = new CustomSpringMethodContextListener();
	private static SpringStat           springStat          = new SpringStat();
	
	public CustomDruidStatInterceptor(){

    }
	
	@Override
    public void afterPropertiesSet() throws Exception {
        SpringStatManager.getInstance().addSpringStat(springStat);
        StatFilterContext.getInstance().addContextListener(statContextListener);
    }

    @Override
    public void destroy() throws Exception {
        StatFilterContext.getInstance().removeContextListener(statContextListener);
    }
    
    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
    	return super.invoke(invocation);
    }

}
